Conversation
🟡 Heimdall Review Status
|
| }); | ||
| } else { | ||
| // None value means deletion, skip | ||
| return None; |
There was a problem hiding this comment.
We'll probably need to track explicit deletions here, so that this can be applied when merging with the on-disk nodes.
| new_children[i] = Some(ptr); | ||
| } | ||
| (Some(d_ptr), None) => { | ||
| // Only on-disk: keep |
There was a problem hiding this comment.
As noted above, we'll need to be able to merge in deletions from the in-memory trie.
|
|
||
| /// Converts a Node to an InMemoryNode for writing to disk. Necessary for merging an in-memory | ||
| /// trie with an on-disk trie | ||
| fn node_to_in_memory_node(&self, node: &Node) -> Result<InMemoryNode, Error> { |
There was a problem hiding this comment.
This can probably consume node to avoid cloning the contents.
There was a problem hiding this comment.
As this is only an in-memory conversion, this can also just implement https://doc.rust-lang.org/std/convert/trait.TryInto.html
| fn in_memory_to_disk_node( | ||
| &mut self, | ||
| context: &mut TransactionContext, | ||
| node: &InMemoryNode, |
There was a problem hiding this comment.
This can probably also consume node to avoid cloning contents.
| context: &mut TransactionContext, | ||
| node: &InMemoryNode, | ||
| ) -> Result<Pointer, Error> { | ||
| let page = self.allocate_page(context)?; |
There was a problem hiding this comment.
We'll want to avoid allocating a fresh page for each node. Ideally this would have a designated page already picked out
This PR contains
InMemoryNodeandInMemoryChildtypes to build recursive in-memory triesbuild_in_memory_trieandbuild_in_memory_trie_recfunctions to build in-memory trie for(Nibbles, Option<TrieValue>)key-value pairs. TheOptionallows for both insertion/update and delete for a key at a given value.set_subtrieandmerge_in_memory_with_diskfunctions which allow merging an in-memory subtrie with an existing on-disk trie at the specified nibbles path.Still in progress:
HashVerificationModeenum which will be used to set the level of trust for hashes, either Ignore (always recompute), Check (optimistic hash checking, i.e. verify hashes and use if correct, otherwise recompute), or UnsafeTrust (blindly trust given hashes- currently using for quick tests but could be removed if deemed too risky)set_subtrieandmerge_in_memory_with_diskfunctionsMore context in the Linear Ticket